frame clock: Better handle non-regular clock cycles
authorAlexander Larsson <alexl@redhat.com>
Fri, 5 Jun 2020 09:30:47 +0000 (11:30 +0200)
committerAlexander Larsson <alexl@redhat.com>
Fri, 5 Jun 2020 09:30:47 +0000 (11:30 +0200)
commit91af8a705b74db6ede1a4e5f0793f44e91b1ffa4
treebf0b061d103f234f04f80ad67a911d3fb70252ef
parent82c314f1af3fca776d4e7796ab7555b7182c8464
frame clock: Better handle non-regular clock cycles

We try to step the frame clock in whole refresh_interval steps, but to
avoid drift and rounding issues we additionally try to converge it to
be synced to the physical vblank (actually the time we get the
frame-drawn message from the compositor, but these are tied together).

However, the convergence to vsync only really makes sense if the new
frame_time actually is tied to the vsync. It may very well be that
some other kind of event (say a network or mouse event) triggered
the redraw, and not a vsync presentation.

We used to assume that all frames that are close in time (< 4 frames
apart) were regular and thus tied to the vsync, but there is really no
guarantee of that. Even non regular times could be rapid.

This commit changes the code to only do the convergence-to-real-time
if the cause of the clock cycle was a thaw (i.e. last frame drawn and
animating). Paint cycles for any other kind of reason are always
scheduled an integer number of frames after the last cycle that was
caused by a thaw.
gdk/gdkframeclockidle.c